package com.yuanheng100.ems4j.mapper;

import com.yuanheng100.ems4j.model.Ems4jSMS;

import static org.apache.ibatis.jdbc.SqlBuilder.*;

public class Ems4jSMSSqlProvider
{

    public String insertSelective(Ems4jSMS record)
    {
        BEGIN();
        INSERT_INTO("ems4j_sms");

        if (record.getSmsId() != null)
        {
            VALUES("smsId", "#{smsId,jdbcType=INTEGER}");
        }

        if (record.getContent() != null)
        {
            VALUES("content", "#{content,jdbcType=VARCHAR}");
        }

        if (record.getReceiver() != null)
        {
            VALUES("receiver", "#{receiver,jdbcType=BIGINT}");
        }

        if (record.getFromName() != null)
        {
            VALUES("fromName", "#{fromName,jdbcType=VARCHAR}");
        }

        if (record.getToName() != null)
        {
            VALUES("toName", "#{toName,jdbcType=VARCHAR}");
        }

        if (record.getFromDate() != null)
        {
            VALUES("fromDate", "#{fromDate,jdbcType=TIMESTAMP}");
        }

        if (record.getResult() != null)
        {
            VALUES("result", "#{result,jdbcType=SMALLINT}");
        }

        return SQL();
    }

    public String updateByPrimaryKeySelective(Ems4jSMS record)
    {
        BEGIN();
        UPDATE("ems4j_sms");

        if (record.getContent() != null)
        {
            SET("content = #{content,jdbcType=VARCHAR}");
        }

        if (record.getReceiver() != null)
        {
            SET("receiver = #{receiver,jdbcType=BIGINT}");
        }

        if (record.getFromName() != null)
        {
            SET("fromName = #{fromName,jdbcType=VARCHAR}");
        }

        if (record.getToName() != null)
        {
            SET("toName = #{toName,jdbcType=VARCHAR}");
        }

        if (record.getFromDate() != null)
        {
            SET("fromDate = #{fromDate,jdbcType=TIMESTAMP}");
        }

        if (record.getResult() != null)
        {
            SET("result = #{result,jdbcType=SMALLINT}");
        }

        WHERE("smsId = #{smsId,jdbcType=INTEGER}");

        return SQL();
    }
}